#region File Description
//-----------------------------------------------------------------------------
// InputState.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#endregion

#region Using Statements
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
#endregion

namespace XDL.Framework.Input
{
    /// <summary>
    /// Helper for reading input from keyboard and gamepad. This class tracks both
    /// the current and previous state of both input devices, and implements query
    /// properties for high level input actions such as "move up through the menu"
    /// or "pause the game".
    /// </summary>
    public abstract class InputState
    {
        /// <summary>
        /// Checks for a "menu up" input action, from any player,
        /// on either keyboard or gamepad.
        /// </summary>
        public abstract bool MenuUp
        {
            get;
        }


        /// <summary>
        /// Checks for a "menu down" input action, from any player,
        /// on either keyboard or gamepad.
        /// </summary>
        public abstract bool MenuDown
        {
            get;
        }


        /// <summary>
        /// Checks for a "menu select" input action, from any player,
        /// on either keyboard or gamepad.
        /// </summary>
        public abstract bool MenuSelect
        {
            get;
        }


        /// <summary>
        /// Checks for a "menu cancel" input action, from any player,
        /// on either keyboard or gamepad.
        /// </summary>
        public abstract bool MenuCancel
        {
            get;
        }


        /// <summary>
        /// Checks for a "pause the game" input action, from any player,
        /// on either keyboard or gamepad.
        /// </summary>
        public virtual bool PauseGame
        {
            get
            {
                return IsNewKeyPress(Keys.Escape) ||
                       IsNewButtonPress(Buttons.Back);
            }
        }

        /// <summary>
        /// Reads the latest state of the keyboard and gamepad.
        /// </summary>
        public abstract void Update();

        /// <summary>
        /// Helper for checking if a key was newly pressed during this update,
        /// by any player.
        /// </summary>
        public abstract bool IsNewKeyPress(Keys key);
        public abstract bool IsNewKeyPress(Keys key, PlayerIndex playerIndex);

        /// <summary>
        /// Helper for checking if a button was newly pressed during this update,
        /// by any player.
        /// </summary>
        public abstract bool IsNewButtonPress(Buttons button);
        public abstract bool IsNewButtonPress(Buttons button, PlayerIndex playerIndex);

        public abstract KeyboardState GetKeyboardState(PlayerIndex playerIndex);

        public abstract GamePadState GetGamePadState(PlayerIndex playerIndex);

        /// <summary>
        /// Returns input direction (for players only)
        /// </summary>
        public abstract Vector2 Move(PlayerIndex playerIndex);

        public abstract bool IsActionPressed(PlayerIndex playerIndex);

        public abstract bool IsFirePressed(PlayerIndex playerIndex);
        public abstract bool IsFirePressed(PlayerIndex playerIndex, bool isSingleShot);

        public abstract bool StartGame(PlayerIndex index);
    }
}
